import React, { Component } from 'react'


import store from '../store';
import {
  increAction,
  decreAction,
  increAsyncAction,
} from '../store/action/count';
export default class count extends Component {
  input = React.createRef();
  incre = (val) => {
    store.dispatch(increAction(val));
  };
  decre = () => {
    store.dispatch(decreAction());
  };
  increAsync =(val,time)=>{
    store.dispatch(increAsyncAction(val,time));
  }
  render() {
    return (
      <div>
        {store.getState().count.num}
        <button onClick={()=>{this.incre("1")}}>+1</button>
        <button onClick={this.decre}>-1</button>
        <input type="text" ref={this.input} />
        <button onClick={()=>{this.incre(this.input.current.value)}}>点击加数值</button>
        <button onClick={()=>{this.increAsync("1","500")}}>异步加</button>
      </div>
    );
  }
}
